package cn.com.vs.utils;

import java.util.List;

import cn.com.vs.service.RedisService;

public class NoticeUtils {
	
	private static String makeNoticeMesaage(int fromUser,String type,String message){
		StringBuilder sb = new StringBuilder();
		sb.append(fromUser);
		sb.append("|");
		sb.append(type);
		sb.append("|");
		sb.append(message);
		return sb.toString();
	}
	
	public static boolean makeNewFriendNoticeOfUser(int userid,int friendid,String msg){
		return RedisService.getInstance().publishNotice(String.valueOf(friendid),
				makeNoticeMesaage(userid, "NEW", msg));
	}
	
	public static boolean makeApplyNoticeOfUser(int userid,int friendid,String msg){
		return RedisService.getInstance().publishNotice(String.valueOf(friendid),
				makeNoticeMesaage(userid, "APPLY", msg));
	}
	
	public static boolean makeTalkNoticeOfUser(int userid,List<String> noticeMembers,String msg){
		if( noticeMembers.size() == 0 ){
			System.out.println("++:userid talk user list is empty");
			return true;
		}
		return RedisService.getInstance().publishNotice(noticeMembers,
				makeNoticeMesaage(userid, "TALK", msg));
	}
	
	public static boolean makeCommentNoticeOfUser(int userid,int toUser,String msg){
		return RedisService.getInstance().publishNotice(String.valueOf(toUser),
				makeNoticeMesaage(userid, "COMMENT", msg));
	}
	
	public static boolean makeNewContactRegistedNotice(int userid,String msg){
		return RedisService.getInstance().publishNotice(String.valueOf(userid),
				makeNoticeMesaage(userid, "CONTACTREGISTED", msg));
	}
}
